unit departdeal;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Mask, Vcl.DBCtrls,
  DBGridEh, MemTableDataEh, Db, DBAccess, Uni, DataDriverEh, MemTableEh,
  DBCtrlsEh, DBLookupEh, dxdbtrel;

type
  Tfrmdepartdeal = class(TForm)
    lbl1: TLabel;
    departname: TDBEdit;
    lbl2: TLabel;
    phone: TDBEdit;
    lbl3: TLabel;
    lbl4: TLabel;
    memo: TDBMemo;
    sortid: TDBEdit;
    lbl5: TLabel;
    btnsave: TButton;
    btnclose: TButton;
    dbtreepid: TdxDBLookupTreeView;
    procedure FormShow(Sender: TObject);
    procedure btnsaveClick(Sender: TObject);
    procedure btncloseClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    IsModify:boolean;
  end;

var
  frmdepartdeal: Tfrmdepartdeal;

implementation
uses
DM,MyUtility;

{$R *.dfm}

procedure Tfrmdepartdeal.btncloseClick(Sender: TObject);
begin
  Close;
end;

procedure Tfrmdepartdeal.btnsaveClick(Sender: TObject);
begin
  if dbtreepid.Text='' then
  DataModule1.unidepart.fieldbyname('pid').AsInteger:=0;
  DataModule1.unidepart.FieldByName('zjm').asstring:=chntopy(Trim(departname.text));
  DataModule1.unidepart.Post;
  close;
end;

procedure Tfrmdepartdeal.FormShow(Sender: TObject);
begin
  DataModule1.unidepartlook.Active:=true;

  if not IsModify then
    DM.DataModule1.unidepart.Insert
  else
  DataModule1.unidepart.Edit;
end;

end.
